<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>昵称</title>
    <script src="font/iconfont.js"></script>
    <style>
        h2,p,ul,body{
            padding: 0;
            margin: 0;
        }
        body{
            background-color: rgb(242, 242, 242);
        }
        a{
            text-decoration: none;

        }
        .title{
            background-color: rgb(255, 255, 255);
            list-style: none;
            position: fixed;
            left: 0;
            top: 0; 
            width: 100%;
            height: 45px;                
            z-index: 9; 
        }
        .title .icon{
            width: 40px;
            height: 30px;
            position: relative;
            margin-top: 7px;
            z-index: 9;
        }
        .title h2{
            font-size: 20px;
            text-align: center;
            position: relative;
            bottom: 32px;
        }
        #name{
            width: 96%;
            height: 65px;
            background-color: #fff;
            display: flex;
            margin-top: 55px;
            margin-left: 2%;
            border-radius: 10px;
        }
        #name p{
            margin-left: 30px;
            margin-top: 20px;
            font-size: 17px;
        }
        #user{
            font-size: 17px;
            border: none;
            outline: none;
            flex-grow: 1;
            margin-top: 22px;
        }
        div.input{
            width: 100px;
            margin-left: 60px;
        }
        #require{
            font-size: 14px;
            margin-left: 10px;
            margin-top: 30px;
            color: rgb(153, 153, 153);
        }
        .error{
            font-size: 12px;
            font-weight: bold;
            color: #f00;
            display: none;
        }
        .box{
            width: 84%;
            height: 40px;
            background-color: rgb(143,142,212);
            border-radius: 80px;
            margin-top: 350px;
            margin-left: 8%;            
        }
        #confirm{
            display: inline-block;
            position: relative;
            top: 20%;
            left: 45%;
            color: #fff;
            background-color: rgb(143,142,212);
            border: none;
        }
    </style>
</head>
<body>
    <div class="title">
        <a href="./U4.html">
            <svg class="icon" aria-hidden="true">
                <use xlink:href="#icon-zuojiantou"></use>
            </svg>
        </a>
        <h2>修改昵称</h2>
    </div>
    <form action="./U4.html" method="post" 
    id="fm" name="fm" onsubmit="return checkform()">
    <div id="name">
            <p>昵称</p>
                <div class="input">
                    <input type="text" placeholder="韩旭" name="user" id="user">
                    <span class="error">昵称应为2-16位</span>
                </div>
    </div>
    <p id="require">以英文、汉字或数字开头，2-16个字符，汉字占2个字符</p>
    <p id="require">成风 Wind</p>
    <div class="box">
        <input id="confirm" type="submit" value="确认">
    </div>
    </form>
    <script>
        var user=document.getElementById("user");
        var error=document.getElementsByClassName("error");
        user.onchange=checkuser;
        function checkuser(){
            if(user.value.length>=2&&user.value.length<=13){
                error[0].style.display="none";
                return 1;
            }
            else{
                error[0].style.display="block";
                return 0;
            }
        }
        function checkform(){
            var rs=checkuser();
            if(rs==0){
                return false;
            }
            return true;
        }
    </script>
</body>
</html>